
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Will
 */
public class Usuario extends javax.swing.JFrame {

    int contClic=0;
    /**
     * Creates new form Clientes
     */
    public Usuario() {
        initComponents();
        estadoTelefono();
        tfPass1.setEchoChar('@');
        tfPass2.setEchoChar('@');
        
    }
    
    public void estadoTelefono(){
        l1.setVisible(false);
        l2.setVisible(false);
        l3.setVisible(false);
        l4.setVisible(false);
        l5.setVisible(false);
        tfTel1.setVisible(false);
        tfTel2.setVisible(false);
        tfTel3.setVisible(false);
        tfTel4.setVisible(false);
        tfTel5.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelRect4 = new org.edisoncor.gui.panel.PanelRect();
        labelMetric1 = new org.edisoncor.gui.label.LabelMetric();
        panelRect5 = new org.edisoncor.gui.panel.PanelRect();
        panelRound2 = new org.edisoncor.gui.panel.PanelRound();
        panelImage1 = new org.edisoncor.gui.panel.PanelImage();
        labelMetric3 = new org.edisoncor.gui.label.LabelMetric();
        tfNom = new org.edisoncor.gui.textField.TextFieldRectBackground();
        labelMetric4 = new org.edisoncor.gui.label.LabelMetric();
        tfApe1 = new org.edisoncor.gui.textField.TextFieldRectBackground();
        labelMetric5 = new org.edisoncor.gui.label.LabelMetric();
        tfApe2 = new org.edisoncor.gui.textField.TextFieldRectBackground();
        tfDir = new org.edisoncor.gui.textField.TextFieldRectBackground();
        labelMetric6 = new org.edisoncor.gui.label.LabelMetric();
        labelMetric8 = new org.edisoncor.gui.label.LabelMetric();
        tfTel = new javax.swing.JFormattedTextField();
        l1 = new org.edisoncor.gui.label.LabelMetric();
        l2 = new org.edisoncor.gui.label.LabelMetric();
        l3 = new org.edisoncor.gui.label.LabelMetric();
        l4 = new org.edisoncor.gui.label.LabelMetric();
        l5 = new org.edisoncor.gui.label.LabelMetric();
        tfTel1 = new javax.swing.JFormattedTextField();
        tfTel3 = new javax.swing.JFormattedTextField();
        tfTel4 = new javax.swing.JFormattedTextField();
        tfTel2 = new javax.swing.JFormattedTextField();
        tfTel5 = new javax.swing.JFormattedTextField();
        btnAdd = new org.edisoncor.gui.button.ButtonIcon();
        btnElim = new org.edisoncor.gui.button.ButtonIcon();
        panelImage21 = new org.edisoncor.gui.panel.PanelImage();
        labelMetric9 = new org.edisoncor.gui.label.LabelMetric();
        tfUsu = new org.edisoncor.gui.textField.TextFieldRectBackground();
        labelMetric10 = new org.edisoncor.gui.label.LabelMetric();
        labelMetric11 = new org.edisoncor.gui.label.LabelMetric();
        labelMetric12 = new org.edisoncor.gui.label.LabelMetric();
        tfPass1 = new javax.swing.JPasswordField();
        tfPass2 = new javax.swing.JPasswordField();
        cbPuesto = new javax.swing.JComboBox();
        panelCurves1 = new org.edisoncor.gui.panel.PanelCurves();
        btnGuardar = new org.edisoncor.gui.button.ButtonIpod();
        btnLimpiar = new org.edisoncor.gui.button.ButtonIpod();
        btnRegresar = new org.edisoncor.gui.button.ButtonIpod();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setUndecorated(true);

        labelMetric1.setText("USUARIOS");
        labelMetric1.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
        panelRect4.add(labelMetric1);

        getContentPane().add(panelRect4, java.awt.BorderLayout.PAGE_START);

        panelRect5.setColorPrimario(new java.awt.Color(0, 204, 51));
        panelRect5.setColorSecundario(new java.awt.Color(0, 102, 51));

        panelRound2.setColorSecundario(new java.awt.Color(51, 0, 255));
        panelRound2.setGradiente(org.edisoncor.gui.panel.Panel.Gradiente.CENTRAL);

        panelImage1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos personales", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(255, 255, 255))); // NOI18N

        labelMetric3.setText("Nombre(s):");

        labelMetric4.setText("Primer Apellido:");

        labelMetric5.setText("Segundo Apellido:");

        labelMetric6.setText("Dirección:");

        labelMetric8.setText("Telefono:");

        try {
            tfTel.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tfTel.setText("-");

        l1.setText("Telefono:");

        l2.setText("Telefono:");

        l3.setText("Telefono:");

        l4.setText("Telefono:");

        l5.setText("Telefono:");

        try {
            tfTel1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tfTel1.setText("-");

        try {
            tfTel3.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tfTel3.setText("-");

        try {
            tfTel4.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tfTel4.setText("-");

        try {
            tfTel2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tfTel2.setText("-");

        try {
            tfTel5.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        tfTel5.setText("-");

        btnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/add.png"))); // NOI18N
        btnAdd.setText("buttonIcon1");
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });

        btnElim.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/cancel.png"))); // NOI18N
        btnElim.setText("buttonIcon1");
        btnElim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnElimActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelImage1Layout = new javax.swing.GroupLayout(panelImage1);
        panelImage1.setLayout(panelImage1Layout);
        panelImage1Layout.setHorizontalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelImage1Layout.createSequentialGroup()
                        .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelMetric5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelMetric6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelMetric4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelMetric3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelMetric8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tfDir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(panelImage1Layout.createSequentialGroup()
                                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(tfNom, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tfApe1, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tfApe2, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(panelImage1Layout.createSequentialGroup()
                                        .addComponent(tfTel, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(btnElim, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(0, 149, Short.MAX_VALUE))))
                    .addGroup(panelImage1Layout.createSequentialGroup()
                        .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelImage1Layout.createSequentialGroup()
                                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(l5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(l3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(l4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(panelImage1Layout.createSequentialGroup()
                                        .addGap(81, 81, 81)
                                        .addComponent(tfTel3, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage1Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(tfTel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(tfTel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                            .addGroup(panelImage1Layout.createSequentialGroup()
                                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(l1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(l2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(81, 81, 81)
                                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(tfTel2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tfTel1, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        panelImage1Layout.setVerticalGroup(
            panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage1Layout.createSequentialGroup()
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelMetric3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfNom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelMetric4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfApe1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelMetric5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfApe2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelMetric6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelMetric8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tfTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 21, Short.MAX_VALUE)
                        .addComponent(btnElim, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(l1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(l2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(l3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(l4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(l5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 6, Short.MAX_VALUE))
        );

        panelImage21.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos de usuario", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(255, 255, 255))); // NOI18N

        labelMetric9.setText("Usuario:");

        labelMetric10.setText("Contraseña:");

        labelMetric11.setText("Verifique\nContraseña"); // NOI18N

        labelMetric12.setText("Puesto:");

        tfPass1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tfPass1FocusLost(evt);
            }
        });

        tfPass2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tfPass2FocusLost(evt);
            }
        });

        cbPuesto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Bodeguero", "Vendedor", "Administrador" }));

        javax.swing.GroupLayout panelImage21Layout = new javax.swing.GroupLayout(panelImage21);
        panelImage21.setLayout(panelImage21Layout);
        panelImage21Layout.setHorizontalGroup(
            panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage21Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panelImage21Layout.createSequentialGroup()
                            .addComponent(labelMetric12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(114, 114, 114))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImage21Layout.createSequentialGroup()
                            .addComponent(labelMetric11, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)))
                    .addGroup(panelImage21Layout.createSequentialGroup()
                        .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelMetric10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelMetric9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(90, 90, 90)))
                .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tfUsu, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(cbPuesto, javax.swing.GroupLayout.Alignment.LEADING, 0, 142, Short.MAX_VALUE)
                        .addComponent(tfPass2, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(tfPass1, javax.swing.GroupLayout.Alignment.LEADING)))
                .addContainerGap(130, Short.MAX_VALUE))
        );
        panelImage21Layout.setVerticalGroup(
            panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImage21Layout.createSequentialGroup()
                .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelMetric9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfUsu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelMetric10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfPass1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelMetric11, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfPass2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelImage21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelMetric12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbPuesto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(1, 1, 1))
        );

        javax.swing.GroupLayout panelRound2Layout = new javax.swing.GroupLayout(panelRound2);
        panelRound2.setLayout(panelRound2Layout);
        panelRound2Layout.setHorizontalGroup(
            panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound2Layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addGroup(panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(panelImage21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelImage1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(57, Short.MAX_VALUE))
        );
        panelRound2Layout.setVerticalGroup(
            panelRound2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelImage1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(panelImage21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(150, Short.MAX_VALUE))
        );

        panelCurves1.setLayout(new java.awt.FlowLayout());

        btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/guardar.png"))); // NOI18N
        btnGuardar.setText("Guardar");
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });
        panelCurves1.add(btnGuardar);

        btnLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/limpiar.png"))); // NOI18N
        btnLimpiar.setText("Limpiar");
        btnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarActionPerformed(evt);
            }
        });
        panelCurves1.add(btnLimpiar);

        btnRegresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/cancelar.png"))); // NOI18N
        btnRegresar.setText("Cancelar");
        btnRegresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegresarActionPerformed(evt);
            }
        });
        panelCurves1.add(btnRegresar);

        javax.swing.GroupLayout panelRect5Layout = new javax.swing.GroupLayout(panelRect5);
        panelRect5.setLayout(panelRect5Layout);
        panelRect5Layout.setHorizontalGroup(
            panelRect5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRect5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelRect5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelRect5Layout.createSequentialGroup()
                        .addComponent(panelRound2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(panelCurves1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 687, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelRect5Layout.setVerticalGroup(
            panelRect5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRect5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelRound2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(panelCurves1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        getContentPane().add(panelRect5, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnRegresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegresarActionPerformed
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_btnRegresarActionPerformed
char pass[]=new char[10];
char pass2[]=new char[10];
    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        // TODO add your handling code here:
        String sql;
        String nom=tfNom.getText();
        String ape1=tfApe1.getText();
        String ape2=tfApe2.getText();
        String dir=tfDir.getText();
        String tel=tfTel.getText();
        
        String usu=tfUsu.getText();
        pass=tfPass1.getPassword();
        String puesto=cbPuesto.getSelectedItem().toString().trim();
        
        Boolean tel1=tfTel1.isVisible()&&tfTel1.getText().equals("    -    ");
        Boolean tel2=tfTel2.isVisible()&&tfTel2.getText().equals("    -    ");
        Boolean tel3=tfTel3.isVisible()&&tfTel3.getText().equals("    -    ");
        Boolean tel4=tfTel4.isVisible()&&tfTel4.getText().equals("    -    ");
        Boolean tel5=tfTel5.isVisible()&&tfTel5.getText().equals("    -    ");
        
        if(nom.equals("")||tel.equals("")||dir.equals("")||ape1.equals("")||usu.equals("")||puesto.equals("")||"".equals(tfPass1.getText())||"".equals(tfPass2.getText())||tel1||tel2||tel3||tel4||tel5){
            JOptionPane.showMessageDialog(null, "Sólo el campo segundo apellido no es obligatorio, Complete los demás campos", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
        }else{
            
            Funciones f= new Funciones();
            sql="INSERT INTO usuarios(nombre,primerApellido,segundoApellido,direccion,puesto,activo,usuario,pass) VALUES('"+nom+"','"+ape1+"','"+ape2+"','"+dir+"','"+puesto+"','1','"+usu+"','"+pass+"')";
            f.insertar(sql);
            /////Obtengo el codigo del proveedor ingresado para guardar su telefono
            String codigo="SELECT * FROM usuarios";
            ResultSet rs = f.buscar(codigo);
            int cod = 0;
            try {
                rs.last();
                cod=rs.getInt(1);
            } catch (SQLException ex) {
                Logger.getLogger(Usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
            f.cerrarConexion();
            String sql2="INSERT INTO tel_usuario VALUES('"+cod+"','"+tel+"')";
            f.insertar(sql2);
            
            if(tfTel1.isVisible()){
                if(tfTel1.getText().equals("    -    ")){//Campo telefono vacio
                    JOptionPane.showMessageDialog(null, "No debe dejar campos vacíos", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
                }else{
                    sql2="INSERT INTO tel_usuario VALUES('"+cod+"','"+tfTel1.getText()+"')";
                    f.insertar(sql2);
                }
            }
            if(tfTel2.isVisible()){
                if(tfTel2.getText().equals("    -    ")){//Campo telefono vacio
                    JOptionPane.showMessageDialog(null, "No debe dejar campos vacíos", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
                }else{
                    sql2="INSERT INTO tel_usuario VALUES('"+cod+"','"+tfTel2.getText()+"')";
                    f.insertar(sql2);
                }
            }
            if(tfTel3.isVisible()){
                if(tfTel3.getText().equals("    -    ")){//Campo telefono vacio
                    JOptionPane.showMessageDialog(null, "No debe dejar campos vacíos", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
                }else{
                    sql2="INSERT INTO tel_usuario VALUES('"+cod+"','"+tfTel3.getText()+"')";
                    f.insertar(sql2);
                }
            }
            if(tfTel4.isVisible()){
                if(tfTel4.getText().equals("    -    ")){
                    JOptionPane.showMessageDialog(null, "No debe dejar campos vacíos", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
                }else{
                    sql2="INSERT INTO tel_usuario VALUES('"+cod+"','"+tfTel4.getText()+"')";
                    f.insertar(sql2);
                }
            }
            if(tfTel5.isVisible()){
                if(tfTel5.getText().equals("    -    ")){
                    JOptionPane.showMessageDialog(null, "No debe dejar campos vacíos", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
                }else{
                    sql2="INSERT INTO tel_usuario VALUES('"+cod+"','"+tfTel5.getText()+"')";
                    f.insertar(sql2);
                }
            }
        }
         
    }//GEN-LAST:event_btnGuardarActionPerformed

    private void tfPass1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfPass1FocusLost
        // TODO add your handling code here:
        
        
    }//GEN-LAST:event_tfPass1FocusLost

    private void tfPass2FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfPass2FocusLost
        // TODO add your handling code here:
        pass=tfPass1.getPassword();
        pass2=tfPass2.getPassword();
        
        if(pass.length<=3){
            JOptionPane.showMessageDialog(null, "No se permite una contrase;a muy corta", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
            tfPass1.setText("");
            tfPass2.setText("");
        }
        else{
            if(!Arrays.equals(pass, pass2)){
            JOptionPane.showMessageDialog(null, "Error las contrase;as no coinciden", "ADVERTENCIA", JOptionPane.WARNING_MESSAGE);
            tfPass1.setText("");
            tfPass2.setText("");
            }
        }
        
    }//GEN-LAST:event_tfPass2FocusLost

    private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarActionPerformed
        // TODO add your handling code here:
        this.tfApe1.setText("");
        this.tfApe2.setText("");
        this.tfDir.setText("");
        this.tfNom.setText("");
        this.tfPass1.setText("");
        this.tfPass2.setText("");
        this.tfTel.setText("");
        this.tfUsu.setText("");
        
        
    }//GEN-LAST:event_btnLimpiarActionPerformed

    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
        // TODO add your handling code here:
        contClic++;
        if (contClic == 1) {
            l1.setVisible(true);
            tfTel1.setVisible(true);
        }
        if (contClic == 2) {
            l2.setVisible(true);
            tfTel2.setVisible(true);
        }
        if (contClic == 3) {
            l3.setVisible(true);
            tfTel3.setVisible(true);
        }
        if (contClic == 4) {
            l4.setVisible(true);
            tfTel4.setVisible(true);
        }
        if (contClic == 5) {
            l5.setVisible(true);
            tfTel5.setVisible(true);
        }
        if (contClic > 5) {
            contClic = 5;
        }

    }//GEN-LAST:event_btnAddActionPerformed

    private void btnElimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnElimActionPerformed
        // TODO add your handling code here:

        if (contClic == 1) {
            l1.setVisible(false);
            tfTel1.setVisible(false);
        }
        if (contClic == 2) {
            l2.setVisible(false);
            tfTel2.setVisible(false);
        }
        if (contClic == 3) {
            l3.setVisible(false);
            tfTel3.setVisible(false);
        }
        if (contClic == 4) {
            l4.setVisible(false);
            tfTel4.setVisible(false);
        }
        if (contClic == 5) {
            l5.setVisible(false);
            tfTel5.setVisible(false);
        }
        if (contClic < 1) {
            contClic = 1;
        }
        contClic--;
    }//GEN-LAST:event_btnElimActionPerformed

    /**
     * @param args the command line arguments
     */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.edisoncor.gui.button.ButtonIcon btnAdd;
    private org.edisoncor.gui.button.ButtonIcon btnElim;
    private org.edisoncor.gui.button.ButtonIpod btnGuardar;
    private org.edisoncor.gui.button.ButtonIpod btnLimpiar;
    private org.edisoncor.gui.button.ButtonIpod btnRegresar;
    private javax.swing.JComboBox cbPuesto;
    private org.edisoncor.gui.label.LabelMetric l1;
    private org.edisoncor.gui.label.LabelMetric l2;
    private org.edisoncor.gui.label.LabelMetric l3;
    private org.edisoncor.gui.label.LabelMetric l4;
    private org.edisoncor.gui.label.LabelMetric l5;
    private org.edisoncor.gui.label.LabelMetric labelMetric1;
    private org.edisoncor.gui.label.LabelMetric labelMetric10;
    private org.edisoncor.gui.label.LabelMetric labelMetric11;
    private org.edisoncor.gui.label.LabelMetric labelMetric12;
    private org.edisoncor.gui.label.LabelMetric labelMetric3;
    private org.edisoncor.gui.label.LabelMetric labelMetric4;
    private org.edisoncor.gui.label.LabelMetric labelMetric5;
    private org.edisoncor.gui.label.LabelMetric labelMetric6;
    private org.edisoncor.gui.label.LabelMetric labelMetric8;
    private org.edisoncor.gui.label.LabelMetric labelMetric9;
    private org.edisoncor.gui.panel.PanelCurves panelCurves1;
    private org.edisoncor.gui.panel.PanelImage panelImage1;
    private org.edisoncor.gui.panel.PanelImage panelImage21;
    private org.edisoncor.gui.panel.PanelRect panelRect4;
    private org.edisoncor.gui.panel.PanelRect panelRect5;
    private org.edisoncor.gui.panel.PanelRound panelRound2;
    private org.edisoncor.gui.textField.TextFieldRectBackground tfApe1;
    private org.edisoncor.gui.textField.TextFieldRectBackground tfApe2;
    private org.edisoncor.gui.textField.TextFieldRectBackground tfDir;
    private org.edisoncor.gui.textField.TextFieldRectBackground tfNom;
    private javax.swing.JPasswordField tfPass1;
    private javax.swing.JPasswordField tfPass2;
    private javax.swing.JFormattedTextField tfTel;
    private javax.swing.JFormattedTextField tfTel1;
    private javax.swing.JFormattedTextField tfTel2;
    private javax.swing.JFormattedTextField tfTel3;
    private javax.swing.JFormattedTextField tfTel4;
    private javax.swing.JFormattedTextField tfTel5;
    private org.edisoncor.gui.textField.TextFieldRectBackground tfUsu;
    // End of variables declaration//GEN-END:variables
}
